package cn.iocoder.yudao.module.ad.service.legaladviceclueqa;

import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.transaction.annotation.Transactional;

import java.util.*;
import cn.iocoder.yudao.module.ad.controller.admin.legaladviceclueqa.vo.*;
import cn.iocoder.yudao.module.ad.dal.dataobject.legaladviceclueqa.AdLegalAdviceClueQaDO;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;

import cn.iocoder.yudao.module.ad.dal.mysql.legaladviceclueqa.AdLegalAdviceClueQaMapper;

import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
import static cn.iocoder.yudao.module.ad.enums.ErrorCodeConstants.*;

/**
 * 法律咨询线索对话 Service 实现类
 *
 * @author 数创万维
 */
@Service
@Validated
public class AdLegalAdviceClueQaServiceImpl implements AdLegalAdviceClueQaService {

    @Resource
    private AdLegalAdviceClueQaMapper legalAdviceClueQaMapper;

    @Override
    public Long createLegalAdviceClueQa(AdLegalAdviceClueQaSaveReqVO createReqVO) {
        // 插入
        AdLegalAdviceClueQaDO legalAdviceClueQa = BeanUtils.toBean(createReqVO, AdLegalAdviceClueQaDO.class);
        legalAdviceClueQaMapper.insert(legalAdviceClueQa);
        // 返回
        return legalAdviceClueQa.getId();
    }

    @Override
    public void updateLegalAdviceClueQa(AdLegalAdviceClueQaSaveReqVO updateReqVO) {
        // 更新
        AdLegalAdviceClueQaDO updateObj = BeanUtils.toBean(updateReqVO, AdLegalAdviceClueQaDO.class);
        legalAdviceClueQaMapper.updateById(updateObj);
    }

    @Override
    public void deleteLegalAdviceClueQa(Long id) {
        // 删除
        legalAdviceClueQaMapper.deleteById(id);
    }

    @Override
    public AdLegalAdviceClueQaDO getLegalAdviceClueQa(Long id) {
        return legalAdviceClueQaMapper.selectById(id);
    }

    @Override
    public PageResult<AdLegalAdviceClueQaDO> getLegalAdviceClueQaPage(AdLegalAdviceClueQaPageReqVO pageReqVO) {
        return legalAdviceClueQaMapper.selectPage(pageReqVO);
    }

}